import java.util.Scanner;

public class test3 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        String str = scan.next();
        int[] hash = new int[100];
        for(int l = 0;l<n;l++){
            for(int r = l ; r<n;r++){
                String ret = str.substring(l,r+1);
                int change = change(ret);
                hash[change]++;
//                System.out.println(change);
            }
        }
 //       System.out.println(change("11111"));
        for (int i = 0; i < hash.length; i++) {
            if(hash[i]==0){
                System.out.println(i);
                break;
            }
        }
    }
//二进制转十进制
    private  static int change(String str){
        int sum = 0;
        int ji = 1 ;

        for (int i = str.length()-1; i >=0 ; i--,ji*=2) {
            char c = str.charAt(i);
            int tmp = c-'0';
            sum = sum + (tmp*ji);

        }
        return sum;
    }
}
